package net.sunofbeaches.controller.portal;

import net.sunofbeaches.pojo.Comment;
import net.sunofbeaches.response.ResponseResult;
import net.sunofbeaches.services.CommentServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/portal/comment")
public class CommentPortalApi {
    @Autowired
    private CommentServices commentServices;

    @PutMapping
    public ResponseResult postComment(@RequestBody Comment comment) {
        return commentServices.postComment(comment);
    }

    @GetMapping("/list/{articleId}/{page}/{size}")
    public ResponseResult listComments(@PathVariable("articleId") String articleId,
                                       @PathVariable("page") int page,
                                       @PathVariable("size") int size) {
        return commentServices.listCommentByArticleID(articleId,page,size);
    }

    @DeleteMapping("/{commentId}")
    public ResponseResult deleteComment(@PathVariable("commentId") String commentId){
        return commentServices.deleteCommentById(commentId);
    }
}
